//
//  UGAlignmentButtonViewController.m
//  Example
//
//  Created by admin on 2020/4/16.
//  Copyright © 2020 admin. All rights reserved.
//

#import "UGAlignmentButtonViewController.h"

@interface UGAlignmentButtonViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property(strong, nonatomic) UICollectionView * collectionView;
@property(strong, nonatomic) NSMutableArray * datalist;
@end

@implementation UGAlignmentButtonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
    [self configUI];
}

-(void)configUI{
    self.title = @"UGAlignmentButton";
    [self.view addSubview:self.collectionView];
}
-(void)loadData{

}

-(UICollectionView *)collectionView{

    if (!_collectionView) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.minimumLineSpacing = 0.f;
        flowLayout.minimumInteritemSpacing = 0.f;
        flowLayout.itemSize = CGSizeMake(KWidth, 120);
        flowLayout.headerReferenceSize = CGSizeZero;
        flowLayout.footerReferenceSize = CGSizeZero;
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flowLayout];
        _collectionView.backgroundColor = UIColor.whiteColor;
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.scrollsToTop = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        _collectionView.showsVerticalScrollIndicator = NO;
        [_collectionView registerClass:[DefualCollectionViewCell class] forCellWithReuseIdentifier:@"DefualCollectionViewCell"];

        
    }
    return _collectionView;
}

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}

#pragma mark collectionView

- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
    
    DefualCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DefualCollectionViewCell" forIndexPath:indexPath];
    cell.backgroundColor = UIColor.whiteColor;
    [cell ug_shadowColor:COLORINFO width:3];
    [cell.button setImage:[UIImage imageWithIcon:@"fa-github" backgroundColor:UIColor.whiteColor iconColor:COLORDANGER andSize:CGSizeMake(32, 32)] forState:UIControlStateNormal];
    switch (indexPath.row) {
        case 0:
        {
            cell.button.ug_Alignment = UGAlignmentDefual;
            [cell.button setTitle:@"Defual" forState:UIControlStateNormal];
        }
            break;
        case 1:
        {
            cell.button.ug_Alignment = UGAlignmentLeft;
            [cell.button setTitle:@"Left" forState:UIControlStateNormal];
        }
            break;
        case 2:
        {
            cell.button.ug_Alignment = UGAlignmentRight;
            [cell.button setTitle:@"Right" forState:UIControlStateNormal];
        }
            break;
        case 3:
        {
            cell.button.ug_Alignment = UGAlignmentTop;
            [cell.button setTitle:@"Top" forState:UIControlStateNormal];
        }
            break;
        case 4:
        {
            cell.button.ug_Alignment = UGAlignmentBottom;
            [cell.button setTitle:@"Bottom" forState:UIControlStateNormal];
        }
            break;
            
        default:{
            
        }
            break;
    }
    return cell;
}

- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return 5;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    return CGSizeMake(KWidth/2, KWidth/2);
}

@end
